<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><title>Config File Helper - Bonfire</title><link rel="stylesheet" type="text/css" href="../../styles/main.css"><script language=JavaScript src="../../javascript/main.js"></script><script language=JavaScript src="../../javascript/prettify.js"></script><script language=JavaScript src="../../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.5 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CFile"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="Config_File_Helper"></a>Config File Helper</h1><div class=CBody><p>Functions to aid in reading and saving config items to and from configuration files.</p><p>The config files are expected to be found in the APPPATH .&rsquo;/config&rsquo; folder.&nbsp; It does not currently work within modules.</p><h4 class=CHeading>Author</h4><p>Lonnie Ezell</p><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#Config_File_Helper" >Config File Helper</a></td><td class=SDescription>Functions to aid in reading and saving config items to and from configuration files.</td></tr><tr class="SGroup"><td class=SEntry><a href="#Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#read_config" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">read_config()</a></td><td class=SDescription>Returns an array of configuration settings from a single config file.</td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#write_config" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">write_config()</a></td><td class=SDescription>Saves the passed array settings into a single config file located in the /config directory.</td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#read_db_config" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">read_db_config()</a></td><td class=SDescription>Retrieves the config/database.php file settings. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#write_db_config" id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">write_db_config()</a></td><td class=SDescription>Saves the settings to the config/database.php file.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="read_config"></a>read_config()</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function read_config(</td><td class=PParameter nowrap>$file,</td><td class=PDefaultValuePrefix>&nbsp;&nbsp;</td><td class=PDefaultValue width=100%></td></tr><tr><td></td><td class=PParameter nowrap>$fail_gracefully</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>TRUE</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns an array of configuration settings from a single config file.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>$file</td><td class=CDLDescription>The config file to read.</td></tr><tr><td class=CDLEntry>$fail_gracefully</td><td class=CDLDescription>true/false.&nbsp; Whether to show errors or simply return false.</td></tr></table><h4 class=CHeading>Return</h4><p>An array of settings, or false on failure (when $fail_gracefully = true).</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="write_config"></a>write_config()</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function write_config(</td><td class=PParameter nowrap>$file</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>'',</td></tr><tr><td></td><td class=PParameter nowrap>$settings</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>null</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Saves the passed array settings into a single config file located in the /config directory.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>$file</td><td class=CDLDescription>The config file to write to.</td></tr><tr><td class=CDLEntry>$settigns</td><td class=CDLDescription>An array of key/value pairs to be written to the file.</td></tr></table><h4 class=CHeading>Return</h4><p>true/false</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="read_db_config"></a>read_db_config()</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function read_db_config(</td><td class=PParameter nowrap>$environment</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>null</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Retrieves the config/database.php file settings.&nbsp; Plays nice with CodeIgniter 2.0&rsquo;s multiple environment support.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>$environment</td><td class=CDLDescription>(Optional) The envinroment to get.&nbsp; If empty, will return all environments.</td></tr></table><h4 class=CHeading>Return</h4><p>An array of database settings.</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="write_db_config"></a>write_db_config()</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function write_db_config(</td><td class=PParameter nowrap>$settings</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>null</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Saves the settings to the config/database.php file.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>$settings</td><td class=CDLDescription>The array of database settings.&nbsp; Should be in the format: array( &lsquo;main&rsquo; =&gt; array( &lsquo;setting1&rsquo; =&gt; value, ...&nbsp; ), &lsquo;development&rsquo; =&gt; array( ...&nbsp; ) );</td></tr></table><h4 class=CHeading>Return</h4><p>true/false</p></div></div></div>

</div><!--Content-->


<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->


<div id=Menu><div class=MTitle>Bonfire<div class=MSubTitle>Faster CodeIgniter Development</div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Guides</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MFile><a href="../../files2/installing-txt.html">Installing Bonfire</a></div></div><div class=MEntry><div class=MFile><a href="../../files2/modules/overview-txt.html">Modules Overview</a></div></div><div class=MEntry><div class=MFile><a href="../../files2/auth_notes-txt.html">Understanding Authentication</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent2')">Helpers</a><div class=MGroupContent id=MGroupContent2><div class=MEntry><div class=MFile><a href="address_helper-php.html">Address Helper</a></div></div><div class=MEntry><div class=MFile><a href="application_helper-php.html">Application Helper</a></div></div><div class=MEntry><div class=MFile id=MSelected>Config File Helper</div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent3')">Libraries</a><div class=MGroupContent id=MGroupContent3><div class=MEntry><div class=MFile><a href="../libraries/assets-php.html">Assets</a></div></div><div class=MEntry><div class=MFile><a href="../libraries/template-php.html">Template</a></div></div><div class=MEntry><div class=MFile><a href="../core_modules/users/libraries/auth-php.html">Auth</a></div></div><div class=MEntry><div class=MFile><a href="../libraries/Console-php.html">Console</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent4')">Core Overrides</a><div class=MGroupContent id=MGroupContent4><div class=MEntry><div class=MFile><a href="../core/MY_Controller-php.html">Controllers</a></div></div><div class=MEntry><div class=MFile><a href="../core/MY_Model-php.html">MY_Model</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent5')">Core Modules</a><div class=MGroupContent id=MGroupContent5><div class=MEntry><div class=MFile><a href="../core_modules/emailer/libraries/emailer-php.html">Emailer</a></div></div><div class=MEntry><div class=MFile><a href="../core_modules/migrations/libraries/Migrations-php.html">Migrations</a></div></div><div class=MEntry><div class=MFile><a href="../core_modules/roles/models/permission_model-php.html">Permission_model</a></div></div><div class=MEntry><div class=MFile><a href="../core_modules/roles/models/role_model-php.html">Role_model</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="../controllers/install-php.html">controllers/<wbr>install.php</a></div></div><div class=MEntry><div class=MFile><a href="../core_modules/logs/controllers/developer-php.html">core_modules/.../controllers/<wbr>developer.php</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent6')">Index</a><div class=MGroupContent id=MGroupContent6><div class=MEntry><div class=MIndex><a href="../../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Classes.html">Classes</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Functions.html">Functions</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Variables.html">Variables</a></div></div><div class=MEntry><div class=MIndex><a href="../../index/Files.html">Files</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option  id=MSearchEverything selected value="General">Everything</option><option value="Classes">Classes</option><option value="Files">Files</option><option value="Functions">Functions</option><option value="Variables">Variables</option></select></div><script language=JavaScript><!--
HideAllBut([2, 3, 1, 4, 5], 7);// --></script></div><!--Menu-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function read_config(</td><td class=PParameter nowrap>$file,</td><td class=PDefaultValuePrefix>&nbsp;&nbsp;</td><td class=PDefaultValue width=100%></td></tr><tr><td></td><td class=PParameter nowrap>$fail_gracefully</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>TRUE</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns an array of configuration settings from a single config file.</div></div><div class=CToolTip id="tt2"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function write_config(</td><td class=PParameter nowrap>$file</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>'',</td></tr><tr><td></td><td class=PParameter nowrap>$settings</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>null</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Saves the passed array settings into a single config file located in the /config directory.</div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function read_db_config(</td><td class=PParameter nowrap>$environment</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>null</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Retrieves the config/database.php file settings. </div></div><div class=CToolTip id="tt4"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype prettyprint"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>function write_db_config(</td><td class=PParameter nowrap>$settings</td><td class=PDefaultValuePrefix>&nbsp;=&nbsp;</td><td class=PDefaultValue width=100%>null</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Saves the settings to the config/database.php file.</div></div><!--END_ND_TOOLTIPS-->




<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>


<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>